package com.rpp.controller;

import com.rpp.pojo.Resume;
import com.rpp.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description
 * @Author peng
 * @Date 2020/7/8 2:58 下午
 */
@RestController
@RequestMapping("resume")
public class ResumeController {

    @Autowired
    ResumeService resumeService;

    /**
     * 查询所有列表
     *
     * @return
     */
    @GetMapping("/findAll")
    public List<Resume> findAll() {

        List<Resume> list = resumeService.findAll();
        return list;
    }

    /**
     * 根据主键查询
     *
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Resume findById(Long id) {
        Resume resume = resumeService.findById(id);
        return resume;
    }

    /**
     * 更新或者插入
     *
     * @param resume
     * @return
     */
    @PostMapping("/saveOrUpdate")
    public String saveOrUpdate(Resume resume) {
        resumeService.saveOrUpdate(resume);
        return "success";
    }

    /**
     * 根据主键删除
     *
     * @param id
     */
    @PostMapping("/delete")
    public String deleteById(Long id) {
        resumeService.deleteById(id);
        return "success";
    }

}
